{% extends 'base.html' %}

{% block content %}
<body>
        <div class="layui-fluid">
            <div class="layui-row">
                <form class="layui-form">

                    <div class="layui-form-item">
                        <label for="L_username" class="layui-form-label">父分类名</label>
                        <div class="layui-input-inline">
                            <input value="{{post['fcate_name'] }}" type="text" id="p_cate" name="p_cate" required="" lay-verify="title" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label"></label>
                        <button class="layui-btn" lay-filter="edit" lay-submit="">确定</button>
                    </div>
                </form>
            </div>
        </div>
        <script>
            layui.use(['form', 'layer'],
            function() {
                $ = layui.jquery;
                var form = layui.form,
                layer = layui.layer;

                //自定义验证规则
                form.verify({
                    title:[/\S/,'父分类名不能为空'],
                });

                //监听提交
                form.on('submit()',
                function(data) {
                    console.log(data);
                    $.post(data.form.action,data.field);
                    //发异步，把数据提交
                    layer.alert("修改成功", {
                        icon: 6
                    },

                    function() {
                        // 获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);
                        // 可以对父窗口进行刷新
                        xadmin.father_reload();
                    });
                    return false;
                });

            });
        </script>
    </body>
{% endblock %}